package com.tongcao.cn.domain.bean;

import org.apache.commons.lang3.StringUtils;
import org.eclipse.core.runtime.Assert;

/**
 * @author:tongcao
 * @since:2019/8/1 14:02
 * Description:
 */
public class EnvironmentMode {

    /**
     * 当前运行环境
     */
    private String mode;

    private final static String DEV = "dev";
    private final static String DAILY = "daily";
    private final static String PRE = "pre";
    private final static String PUBLISH = "publish";


    public void setMode(String mode) {
        this.mode = mode;
    }

    public boolean isDevmode() {
        if (DEV.equals(mode)) {
            return Boolean.TRUE;
        } else {
            return Boolean.FALSE;
        }
    }

    public String getMode() {
        return mode;
    }

    public boolean isDailymode() {
        return commonMode(DAILY, mode);
    }

    public boolean isPremode() {
        return commonMode(PRE, mode);
    }

    public boolean isPublishmode() {
        return commonMode(PUBLISH, mode);
    }


    private Boolean commonMode(String constant, String mode) {
        Assert.isNotNull(constant, "not null");
        Assert.isNotNull(mode, "not null");
        if (StringUtils.equals(constant, mode)) {
            return Boolean.TRUE;
        } else {
            return Boolean.FALSE;
        }
    }
}